package com.wxh.multithread;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @ClassName: Testu
 * @Description:
 * @Author wxh
 * @Date: 2022/1/14 10:27
 * @Version V1.0.0
 * @Since 1.8
 */
public class Testu {
    public static void main(String[] args) {
        System.out.println(getDateStr());


        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_MONTH, -1);
        Date dBefore = calendar.getTime();
        String dateStr = sdf.format(dBefore);
        System.out.println(dateStr);
    }


    private static String getDateStr(){
        // 设置日期格式
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String str = df.format(new Date());
        String[] s1= str.split(" ");
        String[] s2= s1[1].split(":");
        StringBuffer resStr = new StringBuffer();
        resStr.append(s1[0]);
        resStr.append(" ");
        resStr.append(s2[0]);
        resStr.append(":");
        resStr.append(s2[1]);
        resStr.append(":00");
        return  resStr.toString();
    }

}
